<template>
	<theme-box title="新增多媒体">
		<form class="form-horizontal" @submit.prevent v-el:form>
			<div class="box-body">

				<div class="row">
					<div class="col-sm-6">
					  <form-input title="媒体标题" name="title" left="3"></form-input>
						<form-group title="选择附件" left="3">
							<file-upload v-ref:fileupload></file-upload>
						</form-group>
					</div>
					<div class="col-sm-6">
						<form-input title="媒体描述" name="description" left="3"></form-input>
						<form-group title="媒体类型" left="3">
							<select class="form-control" name="mediaType">
								<option value="1">video</option>
							</select>
						</form-group>
					</div>
				</div>

			</div>
			<!-- /.box-body -->
			<div class="box-footer">
				<v-button type="reset" @click="reset">重置</v-button>
				<v-button type="submit" theme="primary" class="pull-right" @click="submit">确认</v-button>
			</div>
			<!-- /.box-footer -->
		</form>
	</theme-box>
</template>

<script>

	export default {
		methods: {
			reset() {

			},
			submit() {

				if(!(this.$refs.fileupload.$els.upload.value)){
					let data = {
						title:"操作提示",
						content:"请选择附件"
					}
					Midway.alert(data);
					return false;
				}
				let formData = new FormData(this.$els.form);
		    formData.append("type", "video");
				formData.append("mchtIdFlag",localStorage.getItem('get_id'))				
        this.$postFormData({
          url: "/api/v1" + projectName_Url + "/wechat/mass/mpnews.html",
					data: formData
        }).then(response=>{
					let message = {
						title: "操作提示",
						content: "操作成功"
					}
					Midway.alert(message);
				},error => {});
			}
		},
		ready() {
		}
	}
</script>
